﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Util
{
    public class MD5Code
    {
        public static string GetMD5Code(string password)
        {
            //将 szToHashString转换为字节数组   
            byte[] byteToHash = Encoding.Default.GetBytes(password);
            //创建的   MD5   类的实例   
            System.Security.Cryptography.MD5CryptoServiceProvider csp = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] byteHashValue = csp.ComputeHash(byteToHash);//计算哈希值   
            //将byte数组转化为string   
            string szRetHashString = BitConverter.ToString(byteHashValue);
            return szRetHashString.Replace("-","").ToUpperInvariant();
        }
    }
}
